﻿using AutoMapper;
using BestTrader.Cms.Models;
using BestTrader.Cms.ViewModels;
using System;
using System.Collections.Generic;

namespace BestTrader.Cms.Admin.Profiles
{
    /// <summary>
    /// 返佣记录转换规则
    /// </summary>
    public class RebateRecordExcelResolver : ITypeConverter<RebateRecord, RebateRecordExcelModel>
    {
        private static readonly Dictionary<string, string> UnitNames = new Dictionary<string, string>() { { "HKD", "HK" }, { "USD", "$" }, { "EUR", "€" }, { "JPY", "￥" }, { "CNY", "￥" } };

        public RebateRecordExcelModel Convert(RebateRecord src, RebateRecordExcelModel dest, ResolutionContext context)
        {
            var result = new RebateRecordExcelModel()
            {
                TransactionTime = src.TransactionTime,
                Currency = src.Currency,
                ManagerName = src.ManagerName,
                ManagerRealName = src.ManagerRealName,
                ParentManagerName = src.ParentManagerName,
                PManagerRealName = src.PManagerRealName,
                ProjectCode = src.ProjectCode,
                ProjectName = src.ProjectName,
                Quantity = src.Quantity,
                Remark = src.Remark
                //ServiceChargeMoney = src.ServiceChargeMoney,
                //RebateMoney = src.RebateMoney,
                //RebateRMBMoney = src.RebateRMBMoney
            };
            result.ServiceChargeMoney = $"{UnitNames[src.Currency]}{src.ServiceChargeMoney}";
            result.RebateMoney = $"{UnitNames[src.Currency]}{src.RebateMoney}";
            result.RebateRMBMoney = $"￥{src.RebateRMBMoney}";

            return result;
        }
    }
}
